import ctypes

import requests
from lxml import etree


def VersionControl(fuc):
    """
    版本控制装饰器
    :param fuc:被装饰函数名
    :return:
    """
    resp_data = requests.get("https://blog.csdn.net/weixin_41822224/article/details/86472391")
    html_str = resp_data.text
    # 将html转换成_Element对象
    element = etree.HTML(html_str)

    vesion_str = element.xpath('//*[@id="content_views"]/p[1]/text()')[0]
    def inner(*args, **kwargs):
        if vesion_str == "V2.0":
            fuc(*args, **kwargs)
        else:
            ctypes.windll.user32.MessageBoxA(0, u"版本已经更新到V2.0，\n请找管理员更新版本".encode('gb2312'),
                                     u' 提示 ^_^'.encode('gb2312'), 0)
    return inner



if __name__ == '__main__':
    @VersionControl
    def a():
        print("开始")


    a()